package com.itheima.tlias.mapper;

import com.itheima.tlias.dto.ReportDegreeCountDTO;
import com.itheima.tlias.dto.SelectAllStudentDTO;
import com.itheima.tlias.dto.StudentCountDTO;
import com.itheima.tlias.entity.Student;
import com.itheima.tlias.po.InsertStudentParam;
import com.itheima.tlias.po.SelectStudentPageParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {

    List<SelectAllStudentDTO> selectStudentByPage(@Param("p") SelectStudentPageParam param);

    int insertStudent(@Param("p") InsertStudentParam param);

    int batchDeleteStudent(@Param("ids") List<Integer> ids);

    Student selectStudentById(@Param("id") Integer id);

    int updateStudent(@Param("p") Student param);

    List<ReportDegreeCountDTO> studentDegreeData();

    @Select("select c.name as className,count(s.id) as value from students s" +
            " left join clazz c on c.id = s.clazz_id group by s.clazz_id")
    List<StudentCountDTO> studentCountData();
}
